import { get } from 'lodash-es'

export class TransactionDetail {
  id?: string
  password?: string
  hotel_id?: string
  outlet_id?: string
  business_date?: string | Date
  origin_member_card_id?: string
  member_card_id?: string
  member_uid?: string
  member_number?: string
  transaction_code_id?: string
  transaction_type?: string
  payment_type?: string
  amount?: number
  discount_rate?: number
  net_amount?: number
  gift_amount?: number
  credit_card_number?: string
  reference?: string
  remark?: string
  saler_id?: string
  refund_from_transaction_detail_id?: string
  created_id?: string
  updated_id?: string
  created_at?: string
  updated_at?: string
  version?: number;
  [key: string]: any

  constructor(data?: TransactionDetail) {
    this.init(data)
  }
}

TransactionDetail.prototype.init = function init(data?: TransactionDetail) {
  this.id = get(data, 'id')
  this.password = get(data, 'password')
  this.hotel_id = get(data, 'hotel_id')
  this.outlet_id = get(data, 'outlet_id')
  this.business_date = get(data, 'business_date')
  this.origin_member_card_id = get(data, 'origin_member_card_id')
  this.member_card_id = get(data, 'member_card_id')
  this.member_uid = get(data, 'member_uid')
  this.member_number = get(data, 'member_number')
  this.transaction_code_id = get(data, 'transaction_code_id')
  this.transaction_type = get(data, 'transaction_type')
  this.payment_type = get(data, 'payment_type')
  this.amount = get(data, 'amount')
  this.discount_rate = get(data, 'discount_rate')
  this.discount_rate = get(data, 'discount_rate')
  this.net_amount = get(data, 'net_amount')
  this.gift_amount = get(data, 'gift_amount')
  this.credit_card_number = get(data, 'credit_card_number')
  this.reference = get(data, 'reference')
  this.remark = get(data, 'remark')
  this.saler_id = get(data, 'saler_id')
  this.refund_from_transaction_detail_id = get(data, 'refund_from_transaction_detail_id')
  this.created_id = get(data, 'created_id')
  this.updated_id = get(data, 'updated_id')
  this.created_at = get(data, 'created_at')
  this.updated_at = get(data, 'updated_id')
  this.version = get(data, 'version')
}
